//
//  UILabel+Init.m
//  StaffTax
//
//  Created by 侯伟 on 2020/4/2.
//  Copyright © 2020 侯伟. All rights reserved.
//

#import "UILabel+Init.h"

@implementation UILabel (Init)

+ (instancetype)lableWithFont:(UIFont*)font color:(UIColor*)color text:(NSString* _Nullable)text{
    UILabel* lb = [[UILabel alloc] initWithFont:font color:color text:text];
    return lb;
}

- (instancetype)initWithFont:(UIFont*)font color:(UIColor*)color text:(NSString* _Nullable)text{
    if(self = [super init]){
        self.font = font;
        self.textColor = color;
        self.text = text;
        [self sizeToFit];
    }
    return self;
}


+ (instancetype)tagLabelWithTitle:(NSString *)tag titleColor:(UIColor *)titleColor bgColoer:(UIColor *)bgColoer{
    
    CGSize size = [tag sizeWithAttributes:@{NSFontAttributeName:FONT_FIT(10)}];
    
    UILabel* tagLb = [UILabel lableWithFont:FONT_FIT(10) color:titleColor text:tag];
    tagLb.textAlignment = NSTextAlignmentCenter;
    tagLb.backgroundColor = bgColoer;
    tagLb.myWidth = size.width + 12.0;
    tagLb.myHeight = size.height + 6;
    
    tagLb.layer.masksToBounds = YES;
    tagLb.layer.cornerRadius = 4.0;

    return tagLb;
}

@end
